// var i;
// var a = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.fitWidth = !1;
//         t.fitHeight = !1;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.shezhiShifouShiyingKuanGao = function (e, t) {
//         this.fitWidth = e;
//         this.fitHeight = t;
//         if (this.fitWidth && this.fitHeight) {
//             var o = cc.winSize.width / cc.view.getDesignResolutionSize().width;
//             var i = cc.winSize.height / cc.view.getDesignResolutionSize().height;
//             this.node.scaleX = o;
//             return void (this.node.scaleY = i);
//         }
//         if (this.fitWidth) {
//             var n = cc.winSize.width / cc.view.getDesignResolutionSize().width;
//             this.node.scale = Math.min(n, 1);
//         } else {
//             if (this.fitHeight) {
//                 n = cc.winSize.height / cc.view.getDesignResolutionSize().height;
//                 this.node.scale = Math.min(n, 1);
//             }
//         }
//     };
//     return t;
// })(cc.Component);
// exports.default = a;


/**
 * 这个类继承自cc.Component，用于设置节点的自适应宽高。
 */
class FitComponent extends cc.Component {
    constructor() {
        super();
        /** 是否适应宽度 */
        this.fitWidth = false;
        /** 是否适应高度 */
        this.fitHeight = false;
    }

    /**
     * 设置是否适应宽高
     * @param {boolean} isFitWidth - 是否适应宽度
     * @param {boolean} isFitHeight - 是否适应高度
     */
    shezhiShifouShiyingKuanGao(isFitWidth, isFitHeight) {
        this.fitWidth = isFitWidth;
        this.fitHeight = isFitHeight;

        if (this.fitWidth && this.fitHeight) {
            const scaleX = cc.winSize.width / cc.view.getDesignResolutionSize().width;
            const scaleY = cc.winSize.height / cc.view.getDesignResolutionSize().height;
            this.node.scaleX = scaleX;
            this.node.scaleY = scaleY;
            return;
        }

        if (this.fitWidth) {
            const scale = cc.winSize.width / cc.view.getDesignResolutionSize().width;
            this.node.scale = Math.min(scale, 1);
        } else if (this.fitHeight) {
            const scale = cc.winSize.height / cc.view.getDesignResolutionSize().height;
            this.node.scale = Math.min(scale, 1);
        }
    }
}

exports.default = FitComponent;
